#ifndef _DFONT_H
#define _DFONT_H

//==============================================================================
//
//          DFont - the protocol for classes that implements fonts
//
//               Copyright (C) 2007  Dick van Oudheusden
//  
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2008-07-19 12:28:59 $ $Revision: 1.3 $
//
//==============================================================================

  //
  // The DFT_Glyph structure contains the information to blit one character
  // to a surface.
  //

typedef struct
{
  int                 offsetX;        // the start x offset of the bitmap
  int                 offsetY;        // the start y offset of the bitmap
  int                 advanceX;       // the advance in x direction
  int                 advanceY;       // the advance in y direction
  int                 ascender;       // y distance: top - baseline
  int                 descender;      // y distance: bottom - baseline
  int                 height;         // y distance: top - bottom

  unsigned char      *bitmap;         // bitmap of the character
  int                 bitmapHeight;   // number of rows in the bitmap
  int                 bitmapWidth;    // number of columns in bitmap
  int                 bitmapPitch;    // offset for next row in bitmap
} DFT_Glyph;

//
// The DFont protocol specifies methods that should be implemented by
// classes that act as font.
//

@protocol DFont

  
//// Font members

//
// Get the family name of the font
//
// @return the family name (or NULL)
//
- (const char *) familyName;

//
// Get the style name of the font
//
// @return the style name (or NULL)
//
- (const char *) styleName;

//
// Get the number of characters in font
//
// @return the number of characters in the font (or -1)
//
- (int) glyphsInFont;


//// Font methods

//
// Set the font size based on the width and height of one character
// 
// @param width         the requested width
// @param height        the requested height
//
// @return success
//
- (BOOL) size :(unsigned) width :(unsigned) height;

//
// Set the font size based on a string and requested a size
// 
// @param cstr          the string
// @param width         the requested width
// @param height        the requested height
//
// @return success
//
- (BOOL) size :(const char *) cstr :(unsigned) width :(unsigned) height;

//
// Get the size of a string for the current font size
// 
// @param cstr          the string
// @param width         the width of the string
// @param height        the height of the string
//
// @return success
//
- (BOOL) stringSize :(const char *) cstr :(unsigned *) width :(unsigned *) height;

//
// Get the size of a character for the current font and size
// 
// @param ch            the character
// @param width         the width of the string
// @param height        the height of the string
//
// @return success
//
- (BOOL) charSize :(char) ch :(unsigned *) width :(unsigned *) height;

//
// Get the glyph info for blitting a character for the current font and size
// 
// @param ch            the character
// @param glyph         the character bitmap and blit info
//
// @return success
//
- (BOOL) glyph :(char) ch :(DFT_Glyph *) glyph;

@end

#endif

